import com.sun.deploy.util.StringUtils;

import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.*;

public class Leet476 {
    public static void main(String[] args) {
        Leet476 l = new Leet476();
        System.out.println(l.findComplement(8));
    }
    public int findComplement(int num) {
        int i;
        for (i = 1; i < 31; i++) {
            if (num<1<<i)
                break;
        }
        num = num<<31-i;
        num = num^Integer.MAX_VALUE;
        return num>>(31-i);
    }
}
